using System;
using System.IO;
using System.ComponentModel;
using System.Workflow.ComponentModel;

namespace OWA.Activities
{
	public class FileSystemPackageScope
        : PackageScope
	{
        public static DependencyProperty PathProperty = System.Workflow.ComponentModel.DependencyProperty.Register("Path", typeof(string), typeof(FileSystemPackageScope));

        [Description("The path to the package on the local filesystem.")]
        [Category("OWA")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string Path
        {
            get
            {
                return ((string)(base.GetValue(FileSystemPackageScope.PathProperty)));
            }
            set
            {
                base.SetValue(FileSystemPackageScope.PathProperty, value);
            }
        }

        protected override byte[] LoadPackage()
        {
            return File.ReadAllBytes(Path);
        }

        protected override void SavePackage(byte[] packageContent)
        {
            File.WriteAllBytes(Path, packageContent);
        }
    }
}
